package unit14.blockingQueue;

import java.io.File;
import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class BlockingQueueTest {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		System.out.print("Enter base directory(e.g. /usr/local/jdk1.7.1/src):");
		String directory=in.nextLine();
		System.out.print("Enter keyWord(e.g. volatile):");
		String keyword=in.nextLine();
		final int FILE_QUEUE_SIZE=10;
		final int SEARCH_THREADS=100;
		
		BlockingQueue<File> queue=new ArrayBlockingQueue<>(FILE_QUEUE_SIZE);
		
		FileEnumerationTask enumerator=new FileEnumerationTask(queue,new File(directory));
		new Thread(enumerator).start();
		for(int x=1;x<=SEARCH_THREADS;x++){
			new Thread(new SearchTask(queue, keyword)).start();
			
		}
	}
}
